import CryptoJS from 'crypto-js';

export default class {
    encryptCBC(plainMsg) {
        const key = CryptoJS.enc.Utf8.parse('a4e0b5bha5za9a51');
        const iv = CryptoJS.enc.Utf8.parse('141dfb09efc61e2b');
        const encrypted = CryptoJS.AES.encrypt(plainMsg, key, {
            iv,
            mode: CryptoJS.mode.CBC,
        });
        return encrypted.toString();
    }

    decryptCBC(msg) {
        const key = CryptoJS.enc.Utf8.parse('a4e0b5bha5za9a51');
        const iv = CryptoJS.enc.Utf8.parse('141dfb09efc61e2b');
        const decrypt = CryptoJS.AES.decrypt(msg, key, {
            iv,
            mode: CryptoJS.mode.CBC,
        });
        return decrypt.toString(CryptoJS.enc.Utf8);
    }
}
